<template>
    <view class="scope-container global-shadow-2 data-v-35dbbb07">
        <view @tap="__e" class="item data-v-35dbbb07" :data-event-opts="[['tap', [['toDetail', ['$event']]]]]">
            <view class="body data-v-35dbbb07">
                <view class="name data-v-35dbbb07">{{ info.number }}</view>
                <view class="time-c data-v-35dbbb07">
                    {{ '' + $root.g0 + '' }}
                    <text class="init-text data-v-35dbbb07" v-if="info.source_type === 1">初始获得</text>
                    <block v-else>
                        <block v-if="info.source_type === 2">
                            <image class="headimg data-v-35dbbb07" :src="info.invitee.headimg"></image>
                            {{ '' + info.invitee.name + ' 助力' }}
                        </block>
                        <block v-else>
                            <text class="init-text data-v-35dbbb07" v-if="info.source_type === 3">抽盒赠送</text>
                        </block>
                    </block>
                </view>
            </view>
            <view class="right data-v-35dbbb07">
                <temaplte @__l="__l" class="data-v-35dbbb07" vueId="260c2d71-1" :vueSlots="['default']">
                    <view class="status data-v-35dbbb07" v-if="info.status === 0">等待开奖</view>
                    <block v-else>
                        <view class="status lucky data-v-35dbbb07" v-if="info.status === 1">已中奖</view>
                        <block v-else>
                            <view class="data-v-35dbbb07" v-if="info.status === 2">未中奖</view>
                        </block>
                    </block>
                </temaplte>
            </view>
        </view>
        <view class="title-c data-v-35dbbb07">
            <view class="text data-v-35dbbb07">{{ info.activity.title }}</view>
            <view class="session-c data-v-35dbbb07">{{ '第' + info.session + '期' }}</view>
        </view>
        <view class="prize-item data-v-35dbbb07" v-if="info.status == 1 && sku">
            <view class="left data-v-35dbbb07">
                <view class="title data-v-35dbbb07">{{ sku.title }}</view>
                <view class="sub-title data-v-35dbbb07" v-if="sku.type === 'score'">{{ sku.score + ' ' + scoreAlias }}</view>
                <block v-else>
                    <view class="sub-title data-v-35dbbb07" v-if="sku.type === 'redpack'">{{ sku.redpack / 100 + ' 红包' }}</view>
                    <block v-else>
                        <view class="sub-title data-v-35dbbb07" v-if="sku.type === 'coupon'">{{ '优惠券: ' + (sku.coupon && sku.coupon.title) }}</view>
                        <block v-else>
                            <view class="sub-title data-v-35dbbb07" v-if="sku.type === 'custom'">实物奖品</view>
                        </block>
                    </block>
                </block>
            </view>
            <view class="right data-v-35dbbb07">
                <button @tap="__e" class="check-prize btn bg-orange data-v-35dbbb07" :data-event-opts="[['tap', [['checkPrize', ['$event']]]]]" v-if="info.is_picked">
                    点击查看
                </button>
                <button @tap="__e" class="check-prize btn bg-orange data-v-35dbbb07" :data-event-opts="[['tap', [['getPrize', ['$event']]]]]" v-else>点击领取</button>
            </view>
        </view>
    </view>
</template>

<script>
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/lotteryTicket/components/TicketItem'],
    {
        '8ff5': function (e, t, n) {
            'use strict';

            n.r(t);
            var i = n('e555');
            var o = n.n(i);
            for (var s in i) {
                if (['default'].indexOf(s) < 0) {
                    (function (e) {
                        n.d(t, e, function () {
                            return i[e];
                        });
                    })(s);
                }
            }
            t.default = o.a;
        },
        '9e92': function (e, t, n) {},
        a7dc: function (e, t, n) {
            'use strict';

            n.r(t);
            var i = n('e961');
            var o = n('8ff5');
            for (var s in o) {
                if (['default'].indexOf(s) < 0) {
                    (function (e) {
                        n.d(t, e, function () {
                            return o[e];
                        });
                    })(s);
                }
            }
            n('fef5');
            var c = n('f0c5');
            var u = Object(c.a)(o.default, i.b, i.c, false, null, '35dbbb07', null, false, i.a, void 0);
            t.default = u.exports;
        },
        e555: function (e, t, n) {
            'use strict';

            (function (e) {
                var i = n('4ea4');
                Object.defineProperty(t, '__esModule', {
                    value: true
                });
                t.default = void 0;
                var o = i(n('2eee'));
                var s = i(n('c973'));
                var c = {
                    components: {},
                    data: function () {
                        return {
                            isAddressListening: false
                        };
                    },
                    props: {
                        info: {
                            type: Object
                        }
                    },
                    computed: {
                        sku: function () {
                            return this.info.sku;
                        }
                    },
                    onLoad: function () {
                        return (0, s.default)(
                            o.default.mark(function e() {
                                return o.default.wrap(function (e) {
                                    for (;;) {
                                        switch ((e.prev = e.next)) {
                                            case 0:
                                            case 'end':
                                                return e.stop();
                                        }
                                    }
                                }, e);
                            })
                        )();
                    },
                    beforeDestroy: function () {
                        e.$off('selectAddress');
                    },
                    methods: {
                        toDetail: function () {
                            if (1 === this.info.status) {
                                e.navigateTo({
                                    url: '/pages/myBox/index'
                                });
                            }
                        },
                        checkPrize: function () {
                            if (!this.sku) {
                                e.showModal({
                                    title: '无奖品',
                                    content: '未查到任何奖品~'
                                });
                                return false;
                            }
                            if ('score' === this.sku.type) {
                                e.navigateTo({
                                    url: '/pages/myScore/index'
                                });
                            } else {
                                if ('redpack' === this.sku.type) {
                                    e.navigateTo({
                                        url: '/pages/myRedpack/index'
                                    });
                                } else {
                                    'coupon' === this.sku.type
                                        ? e.navigateTo({
                                              url: '/pages/couponDetail/index?uuid=' + this.sku.coupon.uuid
                                          })
                                        : 'custom' === this.sku.type &&
                                          e.navigateTo({
                                              url: '/pages/orderDetail/index?uuid=' + this.info.order.uuid
                                          });
                                }
                            }
                        },
                        getPrize: function () {
                            var that = this;
                            'custom' !== this.sku.type ||
                                this.sku.is_picked ||
                                e.showModal({
                                    title: '领取实物奖品',
                                    content: '是否填写邮寄地址发货？',
                                    success: function (n) {
                                        if (n.confirm) {
                                            e.showToast({
                                                title: 'yes'
                                            });
                                            that.isAddressListening ||
                                                (e.$once('selectAddress', function (n) {
                                                    that.isAddressListening = false;
                                                    if (n.id) {
                                                        that.$http('/lottery-tickets/'.concat(that.info.uuid, '/pick-prize'), 'POST', {
                                                            address_id: n.id
                                                        }).then(function (n) {
                                                            that.$emit('refresh');
                                                            e.showToast({
                                                                title: '领取成功~',
                                                                icon: 'none'
                                                            });
                                                        });
                                                    }
                                                }),
                                                (that.isAddressListening = true));
                                            e.navigateTo({
                                                url: '/pages/myAddress/index?select=true'
                                            });
                                        }
                                    }
                                });
                        }
                    },
                    filters: {}
                };
                t.default = c;
            }.call(this, n('543d').default));
        },
        e961: function (e, t, n) {
            'use strict';

            n.d(t, 'b', function () {
                return i;
            });
            n.d(t, 'c', function () {
                return o;
            });
            n.d(t, 'a', function () {});
            var i = function () {
                this.$createElement;
                var e = (this._self._c, this.$tool.formatDate(this.info.created_at, 'MM-dd hh:mm'));
                this.setData(
                    Object.assign(
                        {},
                        {
                            $root: {
                                g0: e
                            }
                        }
                    )
                );
            };
            var o = [];
        },
        fef5: function (e, t, n) {
            'use strict';

            var i = n('9e92');
            n.n(i).a;
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'pages/lotteryTicket/components/TicketItem-create-component',
    {
        'pages/lotteryTicket/components/TicketItem-create-component': function (e, t, n) {
            n('543d').createComponent(n('a7dc'));
        }
    },
    [['pages/lotteryTicket/components/TicketItem-create-component']]
]);
</script>
<style>
@import './TicketItem.css';
</style>
